<template>
	<view class="page">
		<navbar backIconName="arrow-left" title="临时入企" :titleStyle="titleStyle"></navbar>
		<scroll-view class="scroll-view_H" scroll-y="true">
			<view :style="{height:statusHeight+'px'}"></view>

			<view class="inCompany-task">
				<view class="task-item">
					<view class="left">
						<view class="top">
							<text style="font-size: 28rpx;color: #1169DB;font-weight: bold;">企业信息</text>
						</view>
						<u-line></u-line>
						<view class="top" style="padding-top: 20rpx;">
							<text class="label-content">企业名称</text>
							<text
								style="flex: 1; font-size: 28rpx;color: #666666;">{{creditCompanyVo.companyName || '-'}}</text>
						</view>
						<u-line></u-line>
						<view class="top" style="padding-top: 20rpx;align-items: center;">
							<view style="display: flex;flex-direction: column;">
								<text class="label-content">统一社会</text>
								<text class="label-content">信用代码</text>
							</view>

							<text
								style="flex: 1; font-size: 28rpx;color: #666666;">{{creditCompanyVo.socialCreditNumber || '-'}}</text>
						</view>
						<u-line></u-line>
						<view class="top" style="padding-top: 20rpx;">
							<text class="label-content">所属行业</text>
							<text
								style="flex: 1; font-size: 28rpx;color: #666666;">{{creditCompanyVo.industryType || '-'}}</text>
						</view>
						<u-line></u-line>
						<view class="top" style="padding-top: 20rpx;">
							<text class="label-content">联系人</text>
							<text
								style="flex: 1; font-size: 28rpx;color: #666666;">{{creditCompanyVo.legalRepresentativeName || '-'}}</text>
						</view>
						<u-line></u-line>
						<view class="top" style="padding-top: 20rpx;border: none;">
							<text class="label-content">联系电话</text>
							<text
								style="flex: 1; font-size: 28rpx;color: #666666;">{{creditCompanyVo.legalRepresentativePhone || '-'}}</text>
						</view>
						<u-line></u-line>
						<view class="top" style="padding-top: 20rpx;border: none;">
							<text class="label-content">地址</text>
							<text
								style="flex: 1; font-size: 28rpx;color: #666666;">{{creditCompanyVo.addressName || '-'}}</text>
						</view>

					</view>

				</view>

				<view class="task-item" style="margin-top: 20rpx;display: flex;">
					<view class="left" style="width: 100%;">
						<view class="top">
							<text style="font-size: 28rpx;color: #1169DB;font-weight: bold;">入企信息</text>
						</view>
						<u-line></u-line>
						<u--form labelPosition="left" :model="formData" :rules="rules" labelWidth="90"
							:labelStyle="{fontSize:'28rpx',color:'#323232',fontWeight:'bold'}" ref="uForm">
							<u-form-item label="入企类型" required borderBottom @click="showTaskType">
								<u--input v-model="formData.taskTypeName" disabled disabledColor="#ffffff"
									placeholder="请选择" border="none"></u--input>
								<u-icon slot="right" name="arrow-right"></u-icon>
							</u-form-item>
							<u-form-item label="所在区域" required borderBottom @click="openLegalPerson">
								<u--input v-model="formData.addressName" disabled disabledColor="#ffffff"
									placeholder="请选择" border="none"></u--input>
								<u-icon slot="right" name="arrow-right"></u-icon>
							</u-form-item>
							<u-form-item label="入企部门" required borderBottom @click="openDeptPop">
								<u--input v-model="formData.departmentName" disabled disabledColor="#ffffff"
									placeholder="请选择" border="none"></u--input>
								<u-icon slot="right" name="arrow-right"></u-icon>
							</u-form-item>
							<u-form-item label="入企任务" required borderBottom>
								<u--textarea v-model="formData.taskName" disabled :showConfirmBar="false" autoHeight
									:adjustPosition="true" placeholder="入企任务"></u--textarea>
							</u-form-item>
							<u-form-item label="入企人数" prop="numbers" borderBottom>
								<u--input v-model="formData.numbers" readonly border="none"></u--input>
							</u-form-item>
							<!-- <template v-if="formData.taskTypeCode == '1'">
								<u-form-item label="审批材料" required>
									<view
										style="font-size: 26rpx; display: flex;align-items: center;justify-content: space-between;">
										<text style="font-size: 22rpx;">最多支持5个文件，最大2M</text>
										<text class="custom-button" @click="selectFile">新增文件</text>
									</view>
								</u-form-item>
								<view class="file-content">
									<view class="item" v-for="(item,index) in fileList" :key="index">
										<text>{{item.name}}</text>
										<u-icon name="close" @click="delFile(item,index)"></u-icon>
									</view>
								</view>
							</template> -->

							<u-form-item label="备注" prop="enterpriseContent">
								<u--textarea v-model="formData.enterpriseContent" :showConfirmBar="false" autoHeight
									:adjustPosition="true" placeholder="请输入此次入企要做的内容"></u--textarea>
							</u-form-item>
							<!-- <u-form-item label="计划入企日期" required borderBottom @click="showStartTime = true;">
								<u--input v-model="formData.enterprisePlanDate" disabled disabledColor="#ffffff"
									placeholder="请选择" border="none"></u--input>
								<u-icon slot="right" name="arrow-right"></u-icon>
							</u-form-item> -->
							<u-form-item v-if="formData.taskTypeCode == '1'" label="检查事项"
								labelPosition="top"></u-form-item>
							<view class="matters-content">
								<view class="item" v-for="(item,index) in formData.enterpriseTaskItemDtoList"
									:key="index">
									<text>{{(index + 1) + '，'}}</text>
									<text class="txt">{{item.itemName}}</text>
									<view @click="delMatter(index)">
										<u-icon name="close" color="#323232" size="18"></u-icon>
									</view>
								</view>
							</view>

						</u--form>

					</view>
				</view>
			</view>
			<view v-if="formData.taskTypeCode == '1'" class="other-staff">
				<text @click="addMatters">添加检查事项</text>
			</view>

			<view class="inCompany-task" style="padding-top: 0px;">
				<view class="task-item" v-for="(item,index) in inCompanyList" :key="index">
					<view class="left">
						<view class="top">
							<text
								style="flex: 1; font-size: 28rpx;color: #1169DB;font-weight: bold;">{{'入企人员信息'+(index+1)}}
							</text>
							<view v-if="index != 0?true:false" class="clear-ico" @click="del(item,index)">
								<u-icon name="close"></u-icon>
							</view>
						</view>
						<u-line></u-line>
						<view class="top" style="padding-top: 20rpx;">
							<text class="label-content">姓名</text>
							<text style="flex: 1; font-size: 28rpx;color: #666666;">{{item.nickName || '-'}}</text>
						</view>
						<u-line></u-line>
						<view class="top" style="padding-top: 20rpx;">
							<text class="label-content">人员类型</text>
							<text
								style="flex: 1; font-size: 28rpx;color: #666666;">{{item.personnelCategory || '-'}}</text>
						</view>
						<u-line></u-line>
						<view class="top" style="padding-top: 20rpx;">
							<text class="label-content">证件编号</text>
							<text style="flex: 1; font-size: 28rpx;color: #666666;">{{item.idNumber || '-'}}</text>
						</view>
						<u-line></u-line>
						<view class="top" style="padding-top: 20rpx;">
							<text class="label-content">所在单位</text>
							<text style="flex: 1; font-size: 28rpx;color: #666666;">{{item.deptName || '-'}}</text>
						</view>
						<u-line></u-line>
						<view class="top" style="padding-top: 20rpx;border: none;">
							<text class="label-content">职务/职级</text>
							<text style="flex: 1; font-size: 28rpx;color: #666666;">{{item.post || '-'}}</text>
						</view>

					</view>

				</view>

			</view>
			<view style="display: flex;">
				<view v-if="formData.taskTypeCode != '1' && formData.taskTypeCode != ''" class="other-staff"
					@click="handMovementPeople">
					<text>添加随行人员</text>
				</view>
				<view v-if="userInfo.isEnterprise" class="other-staff" @click="addOtherPeople">
					<text>添加执法人员</text>
				</view>
			</view>

			<view class="submit-content">
				<u-button v-if="isCreatOver" :throttleTime="1000" type="primary" text="确认入企"
					@click="sureInCompany"></u-button>
			</view>

		</scroll-view>
		<!-- 选择入企类型 -->
		<u-action-sheet :show="showType" :actions="actions" round="12" title="请选择入企类型" @close="showType = false"
			@select="typeSelect">
		</u-action-sheet>

		<!-- 开始时间-->
		<u-datetime-picker v-model="startTime" :show="showStartTime" :minDate="minDate" mode="date"
			@cancel="showStartTime = false" @confirm="planEnterTime"></u-datetime-picker>
		<!-- 结束时间-->
		<u-datetime-picker v-model="overTime" :show="showEndTime" mode="datetime" @cancel="showEndTime = false"
			@confirm="endTimeBack"></u-datetime-picker>

		<!-- 红码提示 -->
		<u-popup :show="showKnown" :round="5" mode="center" :safeAreaInsetBottom="false" @close="closePop">
			<view class="user-notice">
				<text class="title" style="opacity: 0;">提示</text>
				<view class="contains">
					<view class="">
						<text class="content" style="color: #E63C3C;">特别提示：</text>
						<text class="content">您扫码登记提交的信息校验不通过，如红码入企，企业可以拒绝或投诉举报，请理解支持!</text>
					</view>
					<text class="content2" style="margin-top: 16px;">-行政执法类入企，行政执法人员数不足2人;</text>
					<text class="content2">-未填写行政执法事项;</text>
				</view>

				<view style="display: flex; flex-direction: column; width: 100%;margin-top: 30rpx;">
					<u-button color="#E63C3C" type="primary" text="需要入企" @click="stillEnter"></u-button>
					<view style="width: 100%;height: 12px;"></view>
					<u-button color="#E63C3C" plain="true" text="返回修改" @click="showKnown = false"></u-button>
				</view>
			</view>
		</u-popup>


		<!-- 手输入企人员 -->
		<u-popup :show="showHandMovement" :round="5" mode="center" :safeAreaInsetBottom="false"
			@close="closeHandMovementPop">
			<newAddEnterMember ref="newAddEnterMember" @close="showHandMovement = false"
				@confirm="confirmHandMovement" />
		</u-popup>


		<!-- 入企部门所在区域 -->
		<u-picker :show="showLegalPerson" ref="uPickerArear" :columns="columnsArear" keyName="name"
			@confirm="confirmArear" @change="changeHandlerArear" @cancel="showLegalPerson = false"></u-picker>
		<!-- 入企部门 -->
		<u-picker :show="showDept" :columns="columnsDept" keyName="deptName" @confirm="confirmDept"
			@cancel="showDept = false"></u-picker>



		<!-- loading -->
		<u-overlay :show="showLoading" :opacity="0.8">
			<view class="warp">
				<text style="font-size: 28rpx;color: #fff;">{{loadingTips}}</text>
			</view>
		</u-overlay>

		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	import {
		getDict,
	} from '@/api/login'
	import {
		getEnterprise,
		getSysUser,
		listDeptAll,
		treeseDepart,
	} from '@/api/pagesMall'
	import {
		getTimeStamp,
		showConfirm,
	} from "@/utils/common.js"
	import newAddEnterMember from "@/components/newAddEnterMember.vue"
	import store from '@/store'
	import config from '@/api/config'
	let App = getApp();
	export default {
		components: {
			newAddEnterMember,
		},
		data() {
			return {

				showHandMovement: false,
				showKnown: false,
				showLoading: false,
				loadingTips: '上传中...',
				isCreatOver: true,
				showEndTime: false,
				showStartTime: false,
				statusHeight: 44 + App.globalData.statusBarHeight,
				titleStyle: {
					color: "#ffffff",
					fontWeight: "bold",
					fontSize: "18px"
				},
				formData: {
					taskName: "",
					taskTypeCode: "",
					taskTypeName: "",
					addressName: "",
					departmentName: "",
					departmentCode: "",
					numbers: "",
					enterpriseContent: "",
					enterpriseTaskItemDtoList: [],
					enterprisePlanDate: "",
					planStartTime: "",
					planEndTime: "",
				},
				rules: {
					taskName: [{
						required: true,
						message: '请输入任务名称',
						trigger: ['blur']
					}],
					taskTypeName: [{
						required: true,
						message: '请选择入企类型',
						trigger: ['blur']
					}],
					addressName: [{
						required: true,
						message: '请选择行政区划',
						trigger: ['blur']
					}],
					departmentName: [{
						required: true,
						message: '请选择入企部门',
						trigger: ['blur']
					}],
					// enterpriseContent: [{
					// 	required: true,
					// 	message: '请输入入企内容',
					// 	trigger: ['blur']
					// }],
					// enterprisePlanDate: [{
					// 	required: true,
					// 	message: '请选择计划入企日期',
					// 	trigger: ['blur']
					// }],
					enterpriseTaskItemDtoList: [{
						required: true,
						message: '请选择检查事项',
						trigger: ['blur']
					}],
				},
				showType: false,
				actions: [],
				inCompanyList: [],
				creditCompanyVo: null,
				sysUser: null,
				userId: store.state.user.USER_OPENID,
				userInfo: store.state.user.USER_INFO,
				socialCreditNumber: "",
				startTime: "",
				overTime: "",
				fileList: [],
				dataParams: null,
				minDate: 0,
				columnsDept: [],
				columnsArear: [], //地市
				columnDataArear: [], //区县
				showLegalPerson: false,
				showDept: false,
			};
		},
		watch: {
			inCompanyList: {
				handler(value) {
					this.formData.numbers = value.length
				},
				immediate: true,
				deep: true
			}
		},
		created() {
			this.getDictData()
			this.getAreas()
		},
		onLoad(options) {
			this.minDate = new Date().getTime()
			this.startTime = this.$u.date(new Date(), 'yyyy-mm-dd')
			// this.overTime = this.$u.date(new Date(), 'yyyy-mm-dd hh:MM')
			this.formData.enterprisePlanDate = this.startTime
			// this.formData.planStartTime = this.startTime + ':00'
			this.socialCreditNumber = options.socialCreditNumber
			this.getTemporary()
		},
		onReady() {
			//如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
			this.$refs.uForm.setRules(this.rules)
		},
		methods: {
			openDeptPop() {
				if (this.showLegalPerson || this.showType || this.showHandMovement) {
					return
				}
				if (this.columnsDept.length == 0) {
					if (this.formData.addressName != '') {
						return uni.$u.toast('已选所在区域下未获取到入企部门')
					} else {
						return uni.$u.toast('请先选择所在区域')
					}
				}
				this.showDept = true
			},
			/* 获取入企部门 */
			getObject(id) {
				listDeptAll({
					id: id
				}).then(res => {
					console.log(res, '+++++++++++++数据+++++++++++++')
					this.columnsDept = (res.data && res.data.length > 0) ? [res.data] : []
				})
			},
			// 回调参数为包含columnIndex、value、values
			confirmArear(e) {
				console.log(e)
				this.showLegalPerson = false
				if (e.value[1] == undefined) {
					this.formData.addressName = e.value[0].name
					this.formData.addressId = e.values[1].id
					this.getObject(e.values[1].id)
				} else {
					this.formData.addressName = e.value[0].name + '-' + e.value[1].name
					this.formData.addressId = e.value[1].id
					this.getObject(e.value[1].id)
				}
				this.formData.departmentName = ""
				this.formData.departmentCode = ""

			},
			/* 获取行政区划 */
			getAreas() {
				treeseDepart()
					.then(res => {
						let columnsArearData = []
						let dataList = []
						let lists = res.data.subList
						let columnDataArearData = []
						for (let i = 0; i < lists.length; i++) {
							if (lists[i].subList.length > 0) {
								dataList.push(lists[i])
								columnDataArearData.push(lists[i].subList)
							}
						}
						columnDataArearData.unshift({
							id: 1,
							name: '省直属'
						})
						columnsArearData.push(dataList)
						if (columnDataArearData.length > 0) {
							columnsArearData.push(columnDataArearData[0])
						}
						columnsArearData[0].unshift({
							id: 1,
							name: '省直属'
						})
						for (let i = 1; i < columnsArearData[0].length; i++) {
							columnDataArearData[i].unshift({
								id: columnsArearData[0][i].id,
								name: '市本级'
							})
						}

						this.columnsArear = columnsArearData
						this.columnDataArear = columnDataArearData
						console.log(this.columnsArear)
						console.log(this.columnDataArear)
					})
			},
			/* 倾诉对象所在区域 */
			changeHandlerArear(e) {
				const {
					columnIndex,
					value,
					values, // values为当前变化列的数组内容
					index,
					// 微信小程序无法将picker实例传出来，只能通过ref操作
					picker = this.$refs.uPickerArear
				} = e
				// 当第一列值发生变化时，变化第二列(后一列)对应的选项
				if (columnIndex === 0) {
					// picker为选择器this实例，变化第二列对应的选项
					picker.setColumnValues(1, this.columnDataArear[index])
				}
				console.log('改变了')
			},
			confirmDept(e) {
				this.formData.departmentName = e.value[0].deptName || ''
				this.formData.departmentCode = e.value[0].code
				this.showDept = false
				/* 入企任务名称 */
				this.formData.taskName = this.formData.departmentName + '入企' + this.creditCompanyVo
					.companyName + '开展' + this.formData.taskTypeName

			},
			closePop() {},
			/* 删除文件 */
			delFile(row, index) {
				this.fileList.splice(index, 1)
			},
			/* 选择文件 */
			selectFile() {
				if (this.fileList.length >= 5) {
					return uni.$u.toast('最多支持选择5个文件')
				}
				let fileType = ['pdf', 'doc', 'xlsx', 'docx', 'xls']
				uni.chooseMessageFile({
					count: 1, //默认100
					type: 'file',
					extension: fileType,
					success: (res) => {
						console.log(res)
						if (res.tempFiles[0].size > 1024 * 1024 * 2) {
							return uni.$u.toast('文件大小不能超过2M')
						}
						if (this.fileList.find(item => item.name === res.tempFiles[0].name) != undefined) {
							return uni.$u.toast('存在重复附件')
						}
						this.loadingTips = "上传中..."
						this.showLoading = true
						uni.uploadFile({
							url: config.baseUrl + '/enterprise/upload/uploadFile',
							filePath: res.tempFiles[0].path,
							name: 'file',
							formData: {
								fileName: res.tempFiles[0].name,
								userId: this.userId,
							},
							success: (uploadFileRes) => {
								console.log('asdaggg', JSON.parse(uploadFileRes.data));
								this.showLoading = false
								let result = JSON.parse(uploadFileRes.data)
								if (result.code == 200 && result.data) {
									this.fileList.push({
										name: result.data.fileName,
										url: result.data.url
									})
								} else {
									return uni.$u.toast('上传失败，请重新上传')
								}
							},
							fail: (error) => {
								this.showLoading = false
								return uni.$u.toast('上传失败，请重新上传')
							}
						});


					}
				})
			},
			/* 删除入企事项 */
			delMatter(index) {
				this.formData.enterpriseTaskItemDtoList.splice(index, 1)
			},
			/* 跳转入企事项列表 */
			addMatters() {
				if (this.formData.departmentCode == '') {
					return uni.$u.toast('请选择入企部门')
				}
				let obj = this.columnsDept[0].find(item => item.code == this.formData.departmentCode)
				let systemDomain = encodeURIComponent(obj.systemDomain || '')
				uni.navigateTo({
					url: '/pages-mall/pages/matters/index?systemDomain=' + systemDomain
				})
			},
			getParams(res) {
				if (this.formData.enterpriseTaskItemDtoList.find(item => item.itemId == res.itemId) != undefined) {
					this.$nextTick(() => {
						this.$refs.uToast.show({
							type: "default",
							message: "该检查事项已填加过",
						})
					})
				} else {
					this.formData.enterpriseTaskItemDtoList.push(res)
				}
			},
			getTimeStamp,
			/* 获取临时入企企业信息 */
			getTemporary() {
				getEnterprise({
					socialCreditNumber: this.socialCreditNumber,
					userId: this.userId
				}).then(res => {
					this.creditCompanyVo = res.data.creditCompanyVo || null
					let userInfo = store.state.user.USER_INFO
					let info = null
					if (userInfo.lawEnforcementOfficials != null) { //执法人员
						info = {
							deptCode: '',
							deptName: userInfo.lawEnforcementOfficials.unit || '',
							id: userInfo.lawEnforcementOfficials.id,
							nickName: userInfo.lawEnforcementOfficials.name,
							personnelCategory: '执法人员',
							phonenumber: '',
							post: '',
							idNumber: userInfo.lawEnforcementOfficials.lawEnforcementCertificateNumber,
						}
					} else {
						info = {
							deptCode: '',
							deptName: '',
							id: userInfo.fontUser.id,
							nickName: userInfo.fontUser.userName,
							personnelCategory: '普通人员',
							phonenumber: userInfo.fontUser.mobile,
							post: '',
							idNumber: userInfo.fontUser.idNumber,
						}
					}
					this.sysUser = info
					this.inCompanyList.push(info)
					/* 入企任务名称 */
					this.formData.taskName = this.formData.departmentName + '入企' + this.creditCompanyVo
						.companyName + '开展'
				});
			},
			/* 添加其它人员 */
			addOtherPeople() {
				// let _that = this
				// uni.scanCode({
				// 	success: (res) => {
				// 		this.getUsroInfo(this.getQueryParam(res.result, 'userId'))
				// 	},
				// 	fail: (err) => {
				// 		console.error('扫描失败:', err);
				// 	}
				// })

				/* 跳转执法人员 */
				uni.navigateTo({
					url: '/pages-mall/pages/layerList/index'
				})

			},
			getQueryParam(str, param) {
				const url = str
				// 构造正则表达式，匹配 ? 或 & 后面跟随的参数名称和其值
				const regex = new RegExp('[?&]' + param + '=([^&#]*)', 'i');
				const result = regex.exec(url);
				return result ? decodeURIComponent(result[1]) : '';
			},
			getUsroInfo(userId) {
				getSysUser({
					userId: userId
				}).then(res => {
					if (res.code == 200 && res.data) {
						if (this.inCompanyList.find(item => item.id == res.data.id) == undefined) {
							this.inCompanyList.push(res.data)
						} else {
							uni.$u.toast('请勿重复添加入企人员！')
						}
					}
				});
			},
			/* 删除 */
			del(row, index) {
				this.inCompanyList.splice(index, 1)
			},
			/* 提交 */
			sureInCompany() {
				this.$refs.uForm.validate().then(res => {
					if (this.formData.taskTypeName == '') {
						return uni.$u.toast('请选择入企类型')
					}
					if (this.formData.addressName == '') {
						return uni.$u.toast('请选择所在区域')
					}
					if (this.formData.departmentName == '') {
						return uni.$u.toast('请选择入企部门')
					}
					if (this.formData.taskTypeCode == '1') {

						// if (this.formData.enterpriseTaskItemDtoList.length == 0) {
						// 	return uni.$u.toast('请选择检查事项')
						// }
					}


					console.log(this.fileList)
					let dataParams = {
						"addressName": this.creditCompanyVo.addressName || '',
						"companyName": this.creditCompanyVo.companyName || '',
						"contactNumber": this.creditCompanyVo.legalRepresentativePhone || '',
						"contacts": this.creditCompanyVo.legalRepresentativeName || '',
						"departmentCode": this.formData.departmentCode || '',
						"departmentName": this.formData.departmentName || '',
						"originalDeptCode": this.formData.departmentCode || '',
						"originalDeptName": this.formData.departmentName || '',
						"enterpriseContent": this.formData.enterpriseContent || '',
						"industryType": this.creditCompanyVo.industryType || '',
						"enterprisePlanDate": this.formData.enterprisePlanDate || '',
						"planEndTime": '',
						"planStartTime": '',
						"socialCreditNumber": this.creditCompanyVo.socialCreditNumber || '',
						"taskPersonnelList": [],
						"taskTypeCode": this.formData.taskTypeCode,
						"taskTypeName": this.formData.taskTypeName,
						"taskName": this.formData.taskName,
						"userId": this.userId,
						"enterpriseTaskNo": "",
						"attachmentDtoList": [],
						"enterpriseTaskItemDtoList": this.formData.enterpriseTaskItemDtoList,
						"systemDomain": this.formData.departmentName || '',
					}
					// dataParams.attachmentDtoList = this.fileList.map(item => {
					// 	return {
					// 		fileName: item.name,
					// 		fileUrl: item.url,
					// 		type: ''
					// 	}
					// })

					let remeberList = []
					for (let i = 0; i < this.inCompanyList.length; i++) {
						let params = {
							departmentCode: this.inCompanyList[i].deptCode,
							departmentName: this.inCompanyList[i].deptName,
							lawEnforcerId: this.inCompanyList[i].id,
							lawEnforcerName: this.inCompanyList[i].nickName,
							personnelCategory: this.inCompanyList[i].personnelCategory,
							phoneNumber: this.inCompanyList[i].phonenumber,
							post: this.inCompanyList[i].post,
							idNumber: this.inCompanyList[i].idNumber,
						}
						remeberList.push(params)
					}
					dataParams.taskPersonnelList = remeberList
					let type = dataParams.taskTypeCode == '1' ? '2' : '3'
					if (dataParams.taskTypeCode == '1') { //红码
						if (dataParams.taskPersonnelList.length < 2 || dataParams.enterpriseTaskItemDtoList
							.length == 0) {
							this.dataParams = dataParams
							this.showKnown = true
						} else {
							uni.navigateTo({
								url: '/pages-mall/pages/showCode/index?creatTaskInfo=' + JSON.stringify(
									dataParams) + '&type=' + type
							});
						}
					} else {
						uni.navigateTo({
							url: '/pages-mall/pages/showCode/index?creatTaskInfo=' + JSON.stringify(
								dataParams) + '&type=' + type
						});
					}


				}).catch(errors => {

				})
			},
			/* 任然入企 */
			stillEnter() {
				uni.navigateTo({
					url: '/pages-mall/pages/showErrorCode/index?creatTaskInfo=' + JSON.stringify(this.dataParams)
				});
			},
			/* 入企类型 */
			typeSelect(res) {
				console.log(res)
				if (res.dictValue != '1') {
					this.formData.fileList = []
					this.formData.enterpriseTaskItemDtoList = []
				} else {
					let list = this.inCompanyList.filter(item => item.id != '')
					this.inCompanyList = list
				}
				this.formData.taskTypeCode = res.dictValue
				this.formData.taskTypeName = res.dictLabel
				/* 入企任务名称 */
				this.formData.taskName = this.formData.departmentName + '入企' + this.creditCompanyVo.companyName + '开展' +
					res.dictLabel

			},
			/* 弹出任务类型 */
			showTaskType() {
				if (this.showLegalPerson || this.showDept || this.showHandMovement) {
					return
				}
				this.showType = true
			},
			/* 弹出所在区域 */
			openLegalPerson() {
				if (this.showType || this.showDept || this.showHandMovement) {
					return
				}
				this.showLegalPerson = true
			},
			getDictData() {
				getDict('sys_enterprise_type').then(res => {
					let datas = res.data.map(item => {
						item.name = item.dictLabel
						return item
					})
					let userInfo = store.state.user.USER_INFO
					if (!userInfo.isEnterprise) {
						this.actions = datas.filter(item => item.dictValue != '1')
					} else {
						this.actions = datas
					}
				})
			},
			/* 计划入企时间 */
			planEnterTime(res) {
				if (res.value.length == 10) {
					this.formData.enterprisePlanDate = res.value
				} else {
					this.formData.enterprisePlanDate = this.getTimeStamp(res.value, 1)
				}
				this.showStartTime = false
			},
			/* 开始时间 */
			startTimeBack(res) {
				if (res.value.length == 16) {
					this.formData.planStartTime = res.value + ':00'
				} else {
					this.formData.planStartTime = this.getTimeStamp(res.value) + ':00'
				}
				if (this.formData.planEndTime) {
					if (this.dateStringToTimestamp(this.formData.planStartTime) > this.dateStringToTimestamp(this.formData
							.planEndTime)) {
						this.formData.planStartTime = ''
						return uni.$u.toast('开始时间不能大于结束时间！');
					}

				}
				this.showStartTime = false
			},
			/* 结束时间 */
			endTimeBack(res) {
				this.formData.planEndTime = this.getTimeStamp(res.value) + ':00'
				if (this.formData.planStartTime) {
					if (this.dateStringToTimestamp(this.formData.planEndTime) < this.dateStringToTimestamp(this.formData
							.planStartTime)) {
						this.formData.planEndTime = ''
						return uni.$u.toast('结束时间不能小于开始时间！');
					}
				}
				this.showEndTime = false
			},
			dateStringToTimestamp(str) {
				return new Date(str).getTime();
			},
			closeHandMovementPop() {
				this.showHandMovement = false
			},
			handMovementPeople() {
				if (this.showLegalPerson || this.showDept || this.showType) {
					return
				}
				this.showHandMovement = true
			},
			confirmHandMovement(res) {
				let info = {
					deptCode: '',
					deptName: res.deptName,
					id: '',
					nickName: res.nickName,
					personnelCategory: '普通人员',
					phonenumber: res.mobile,
					post: res.post,
					idNumber: res.idNumber,
				}
				this.inCompanyList.push(info)
				this.showHandMovement = false
			},
			getParamsLawYar(res) {
				console.log(res)
				if (this.inCompanyList.find(item => item.idNumber == res.lawEnforcementCertificateNumber) != undefined) {
					this.$refs.uToast.show({
						type: "default",
						message: "请勿重复添加执法人员！",
					})
					return
				}
				let info = {
					deptCode: '',
					deptName: res.unit || '',
					id: res.id,
					nickName: res.name,
					personnelCategory: '执法人员',
					phonenumber: '',
					post: '',
					idNumber: res.lawEnforcementCertificateNumber,
				}
				this.inCompanyList.push(info)
			}
		}
	};
</script>

<style lang="scss" scoped>
	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.user-notice {
		width: 75vw;
		padding: 30rpx 36rpx;
		display: flex;
		flex-direction: column;
		align-items: center;

		.title {
			font-size: 30rpx;
			color: #E63C3C;
			font-weight: bold;
			padding-bottom: 30rpx;
		}

		.contains {
			height: 25vh;
			overflow: auto;
			display: flex;
			flex-direction: column;

			.content {
				font-size: 28rpx;
				color: #323232;
				// text-indent: 24px;
				line-height: 46rpx;
			}

			.content2 {
				margin-top: 12px;
				font-size: 26rpx;
				color: #666;
				// text-indent: 24px;
				line-height: 32rpx;
			}
		}


	}

	.custom-button {
		width: 160rpx;
		height: 54rpx;
		font-size: 24rpx;
		color: #fff;
		background: #3c9cff;
		border-radius: 6px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.scroll-view_H {
		width: 100%;
		height: 100%;

		.file-content {
			.item {
				font-size: 24rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 12rpx 14rpx;
				border-radius: 8rpx;
				border: 1px solid #eee;
				margin-bottom: 10rpx;

				.txt {
					flex: 1;
					overflow: hidden;
					/*内容超出后隐藏*/
					text-overflow: ellipsis;
					/*超出内容显示为省略号*/
					white-space: nowrap;
					/*文本不进行换行*/
				}
			}
		}



		.matters-content {
			width: 100%;
			margin-top: 12rpx;
			display: flex;
			flex-direction: column;

			.item {
				font-size: 26rpx;
				display: flex;
				align-items: center;
				padding: 12rpx 14rpx;
				border-radius: 8rpx;
				border: 1px solid #eee;
				margin-bottom: 10rpx;

				.txt {
					flex: 1;
					overflow: hidden;
					/*内容超出后隐藏*/
					text-overflow: ellipsis;
					/*超出内容显示为省略号*/
					white-space: nowrap;
					/*文本不进行换行*/
				}
			}
		}

		.submit-content {
			padding: 30rpx;
			height: 200rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
		}

		.other-staff {
			flex: 1;
			height: 80rpx;
			border: 1px dashed #1169DB;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 32rpx;
			color: #1169DB;
			font-weight: bold;
			margin: 0px 20rpx;
			border-radius: 6rpx;
		}

		.inCompany-task {
			display: flex;
			flex-direction: column;
			padding: 20rpx;


			.task-item {
				display: flex;
				align-items: center;
				padding: 20rpx 30rpx;
				background-color: #fff;
				border-radius: 12rpx;
				box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.15);

				.left {
					flex: 1;
					display: flex;
					flex-direction: column;

					.top {
						display: flex;
						align-items: center;
						padding-bottom: 20rpx;

						.clear-ico {
							padding: 10rpx;
						}

						.label-content {
							width: 90px;
							font-size: 28rpx;
							color: #323232;
							font-weight: bold;
						}
					}
				}
			}
		}



	}
</style>